﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using FingerPrintRecognizer.Common;

namespace FingerPrintRecognizer
{
    public class FileLogger:ILogger
    {
        string filePath;
        public FileLogger(string path) {
            this.filePath = path;
        }
        private void logg(string line)
        {
            string[] lines = {line};
            if (System.IO.File.Exists(filePath) == false)
                System.IO.File.Create(filePath);

            System.IO.File.AppendAllLines(this.filePath,lines);
        }
        #region ILogger Members

        public void warn(string msg)
        {
            logg(String.Format("WARNING: [{0}] {1}", DateTime.Now, msg));
        }

        public void err(string msg)
        {
            logg(String.Format("ERROR: [{0}] {1}", DateTime.Now, msg));
        }

        public void info(string msg)
        {
            logg(String.Format("INFO: [{0}] {1}", DateTime.Now, msg));
        }

        public void debug(string msg)
        {
            logg(String.Format("DEBUG: [{0}] {1}", DateTime.Now, msg));
        }

        #endregion
    }
}